<?php
namespace app\api\controller\v1;
use app\api\controller\Common;

class Dynamic extends Common{
	var $modelDb;
	public function _initialize(){
		parent::_initialize();
		$this->modelDb = model("Dynamic");
	}
	public function add_zans(){
		$userid = $this->uinfo['id'];
		$isok = model("Zans")->add_zans($userid, $this->postData['id'], 1);
		if ($isok == -1) {
			$this->app_error('不能重复点赞');
		}
		if ($isok) {
			$zans = $this->modelDb->add_zans($this->postData['id']);
			$this->app_success(['zans'=>$zans]);
		}
	}
	public function index(){
		$userid = $this->uinfo['id'];
    	$data = $this->modelDb->get_lists($this->postData, $userid);
    	if($data){
    		return $this->app_success($data);
    	}
    	else{
    		return $this->app_error("获取失败");
    	}
    }
}